package com.xiaoshuidi.cloud.module.report.convert.finance;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.framework.common.util.date.DateUtils;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.ContractRoomDepositExportRespVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.DepositDetailExportRespVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.DepositDetailRespVO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.DepositDetailDO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportContractRoomDepositDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 权责收入 转换类
 */
@Mapper
public interface ReportContractRoomDepositConvert {

    ReportContractRoomDepositConvert INSTANCE = Mappers.getMapper(ReportContractRoomDepositConvert.class);

    @Mapping(target = "customerType", expression = "java(\"personal\".equals(dto.getCustomerType()) ? \"租客\":\"企业\")")
    @Mapping(target = "contractType", expression = "java(\"personal\".equals(dto.getCustomerType()) ? " +
            "\"租客合同\":\"企业合同\")")
    @Mapping(target = "remainAmount", expression = "java((dto.getDeposit()!=null?dto.getDeposit():java.math" +
            ".BigDecimal.ZERO).subtract(dto.getReturnAmount()!=null?dto.getReturnAmount(): java.math.BigDecimal.ZERO))")
    @Mapping(target = "contractCycle", expression = "java(dto.getStartTime()+\" ~ \"+dto.getEndTime())")
    @Mapping(target = "deposit", expression = "java(dto.getDeposit()!=null?dto.getDeposit():java.math" +
            ".BigDecimal.ZERO)")
    @Mapping(target = "returnAmount", expression = "java(dto.getReturnAmount()!=null?dto.getReturnAmount(): java.math" +
            ".BigDecimal.ZERO)")
    ContractRoomDepositExportRespVO convert(ReportContractRoomDepositDO dto);

    PageResult<ContractRoomDepositExportRespVO> convertPageResult(PageResult<ReportContractRoomDepositDO> dto);

    List<ContractRoomDepositExportRespVO> convertPageList(List<ReportContractRoomDepositDO> dto);


}
